package com.zxx.javapattern.chainOfResponsibility.demo4;

public class SaleDataCheck extends SaleHandler {
    @Override
    public boolean sale(String user, String customer, SaleModel saleModel) {
        //进行通用数据校验
        if(user == null || user.trim().length() ==0  ){
            System.out.println("申请人不能为空...");
            return false;
        }
        if(customer == null || customer.trim().length() ==0 ){
            System.out.println("客户不能为空...");
            return false;
        }

        if(saleModel == null){
            System.out.println("销售商品的数据不能为空...");
            return false;
        }

        if(saleModel.getGoods() == null || saleModel.getGoods().trim().length() == 0){
            System.out.println("销售商品不能为空...");
            return false;
        }
        if(saleModel.getSaleNum() ==0){
            System.out.println("销售商品数量不能为0");
            return false;
        }

        //通过上面的所有校验,向下继续执行
        return successor.sale(user,customer,saleModel);
    }
}
